<!DOCTYPE html>
<html lang="zh-CN">
  <head>

	  <include file="Public:header"/>
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
 	<include file="Public:body_top"/>

    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-3 col-md-2 sidebar hidden-xs">
          <div class="menu">

            <dl>
              <dt><i class="cm-order"></i>小程序设置</dt>
              <dd><a href="{:U('Admins/app_edit')}">小程序配置</a></dd>
            </dl>
            <dl>
              <dt><i class="cm-advert"></i>广告管理</dt>
              <dd><a href="{:U('Admins/adverts_index')}">广告列表</a></dd>
              <dd><a href="{:U('Admins/advert_new')}">新建广告</a></dd>
            </dl>
          </div>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
          <div class="main-hd">
            <h5>编辑广告</h5>
          </div>
          <div class="main-bd">
            <div class="form-box">
              <form class="form-horizontal" id="myform" method="post" enctype="multipart/form-data" action="{:U('Admins/advert_update')}" onsubmit="return validata();">
                <div class="form-group">
                  <label class="col-sm-2 control-label">广告标题</label>
                  <div class="col-sm-8">
                    <input type="text" class="form-control" name="title" value={$advert.title}>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">广告链接</label>
                  <div class="col-sm-8">
                    <input type="text" class="form-control" name="link" value={$advert.link}>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label " >广告图片</label>
                  <div class="col-sm-4">
                    <div class="uploadimg" id="uploadimg">
                      <i class="cm-plus"></i>
                      <input type="file" name="photo" id="phtot"  onchange="xmTanUploadImg(this)">
                      <p class="tips">图片尺寸：720x495</p>
                    </div>
                  </div>
                   <div class="col-sm-4">
                     <img id="xdaTanFileImg" src="{$advert.image}" style=" width:60px; height:60px;">
                   </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">是否开启</label>
                  <div class="col-sm-8">


                        <input type="radio" value="1" name="status" <if condition="$advert.status eq 1">checked</if> > 是
                        <input type="radio" value="2" name="status" <if condition="$advert.status eq 2">checked</if> > 否


                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">排序</label>
                  <div class="col-sm-2">
                    <input type="text" class="form-control" name="orderby" value={$advert.orderby}>
                  </div>
                </div>
                <div class="form-group">
                  <div class="col-sm-offset-2 col-sm-10">
                    <input type="hidden" name="id" value={$advert.id}>
                    <input type="submit" class="btn btn-primary" value="提交">
                    <a class="btn btn-default" href="{:U('Admins/adverts_index')}">返回</a>
                  </div>
                </div>
              </form>
              <script type="text/javascript">
              function validata()
              {

              	$("#myform").ajaxSubmit({
              		type: 'post', // 提交方式 get/post
              		url: "{:U('admins/advert_update')}", // 需要提交的 url
              		datatype:"json",
              		success: function(data) { // data 保存提交后返回的数据，一般为 json 数据
              			// 此处可对 data 作相关处理
              			if(data['code']!='success')
              			{
              			 	save(data['msg']);
              			}
              			else
              			{
              				save(data['msg']);
              			 	location.href="{:U('admins/adverts_index')}";
              			}

              		}
              	});

              	return false;
              }

              </script>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>
